/*******************************************************************************
 * Copyright (c) 2010 Mikhail Garber.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License (LGPL)
 * which accompanies this distribution
 * 
 * Contributors:
 *     Mikhail Garber - initial API and implementation
 ******************************************************************************/
package plumber.model;

import plumber.common.Utils;
import plumber.common.WithId;

/**
 * parent class for a Step outcome.
 * Step outcomes are attached to a FlowStep and are matched against return value of a Step execution
 * @author mgarber
 *
 */
@SuppressWarnings("serial")
public abstract class StepOutcome extends WithId {

	private FlowStep nextStep;

	/**
	 * get Step to be executed next
	 * @return next Step
	 */
	public FlowStep getNextStep() {
		return nextStep;
	}

	public void setNextStep(FlowStep nextStep) {
		this.nextStep = nextStep;
	}
	
	/**
	 * validate this outcome
	 */
	public abstract void validateImpl();
	
	/**
	 * match this Outcome to return value of a Step execution
	 * @param val - return value
	 * @return - true or false if there is a match
	 */
	public abstract boolean match(Object val);
	
	/**
	 * validate this Outcome: next Step must be present
	 */
	public void validate() {
		Utils.validatePresent(nextStep, "next step");
		validateImpl();
	}
}
